home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha Extra 2004 January / CyberMycha Extra 1-2004 (Poland) (Disc 2).bin / Pippi / gmis.dir / Internal_4_isScript.ls < prev    next >
Encoding:
Text File  |  2001-09-10  |  6.4 KB  |  320 lines

  1. property furCnt, furNum, furList, oldFurType, furType, pippi, pippiType, staticPippi, rot, fallen, timerX, xFrame, room, dizzy, dizzyLast
  2. global autoMoveObject, sndObject
  3.  
  4. on new me, pXframe, pRoom
  5.   if voidp(pRoom) = 0 then
  6.     room = pRoom
  7.   else
  8.     room = 1
  9.   end if
  10.   if voidp(pXframe) = 0 then
  11.     xFrame = pXframe
  12.   else
  13.     xFrame = the frame
  14.   end if
  15.   fallen = 0
  16.   staticPippi = 0
  17.   furType = 1
  18.   oldFurType = 1
  19.   furList = []
  20.   pippiType = 0
  21.   pippi = sprite(30)
  22.   timerX = the ticks + 1500
  23.   clearDizzy(me)
  24.   return me
  25. end
  26.  
  27. on traceCursor me, pPos
  28.   if staticPippi = 0 then
  29.     H = pPos[1] - pippi.loc[1]
  30.     v = pPos[2] - pippi.loc[2]
  31.     if (H > 0) and (v > 0) then
  32.       if dizzyLast <> 1 then
  33.         dizzy[1] = dizzy[1] + 1
  34.         dizzyLast = 1
  35.       end if
  36.       if H > v then
  37.         X = 1
  38.       else
  39.         X = 2
  40.       end if
  41.     else
  42.       if (H < 0) and (v > 0) then
  43.         if (H * -1) < v then
  44.           X = 3
  45.         else
  46.           X = 4
  47.         end if
  48.       else
  49.         if (H < 0) and (v < 0) then
  50.           if dizzyLast <> 2 then
  51.             dizzy[2] = dizzy[2] + 1
  52.             dizzyLast = 2
  53.           end if
  54.           if H < v then
  55.             X = 5
  56.           else
  57.             X = 6
  58.           end if
  59.         else
  60.           if (H > 0) and (v < 0) then
  61.             if H < (v * -1) then
  62.               X = 7
  63.             else
  64.               X = 8
  65.             end if
  66.           end if
  67.         end if
  68.       end if
  69.     end if
  70.     if X <> VOID then
  71.       rot = (X * 45) - 110
  72.       pippi.rotation = rot
  73.     end if
  74.     testDizzy(me)
  75.   end if
  76. end
  77.  
  78. on testDizzy me
  79.   if dizzy <> [0, 0] then
  80.     Ok = 1
  81.     repeat with n = 1 to 2
  82.       if dizzy[n] < 3 then
  83.         Ok = 0
  84.         exit repeat
  85.       end if
  86.     end repeat
  87.     if Ok = 1 then
  88.       if sound(2).member = member(1, 1) then
  89.         sound(2).stop()
  90.       end if
  91.       fallXPippi(me)
  92.     end if
  93.   end if
  94. end
  95.  
  96. on clearDizzy me
  97.   dizzyLast = 1
  98.   dizzy = [0, 0]
  99. end
  100.  
  101. on setmember me
  102.   if pippi.member <> member("p" & string(pippiType), 1) then
  103.     pippi.member = member("p" & string(pippiType), 1)
  104.     updateStage()
  105.   end if
  106. end
  107.  
  108. on setPippiHard me, pRot
  109.   staticPippi = 1
  110.   pippi.member = member("p8", 1)
  111.   pippi.rotation = pRot
  112.   updateStage()
  113. end
  114.  
  115. on clearFur me, pNum
  116.   furCnt = 0
  117. end
  118.  
  119. on reportEndFur me, pNum
  120.   furNum = pNum
  121. end
  122.  
  123. on reportLastFur me, pNum
  124.   furList = [furCnt, pNum]
  125. end
  126.  
  127. on reportFur me, pCnt, pFurType, pRot
  128.   if fallen = 0 then
  129.     if furCnt = 0 then
  130.       furCnt = pCnt
  131.     else
  132.       clearDizzy(me)
  133.       timerX = the ticks
  134.       if pCnt = furCnt then
  135.         lookup(me)
  136.       else
  137.         oldFurType = furType
  138.         if (pCnt = (furCnt + 1)) or (pCnt = (furCnt - 1)) then
  139.           furType = pFurType
  140.           furCnt = pCnt
  141.           movePippi(me, pCnt)
  142.           if voidp(pRot) = 0 then
  143.             setPippiHard(me, pRot)
  144.           else
  145.             staticPippi = 0
  146.           end if
  147.         else
  148.           fallPippi(me, pCnt)
  149.         end if
  150.       end if
  151.     end if
  152.   end if
  153. end
  154.  
  155. on lookup me
  156.   if staticPippi = 0 then
  157.     orgType = pippiType
  158.     pippiType = 0
  159.     setmember(me)
  160.     v = the ticks + 15
  161.     repeat while the ticks < v
  162.     end repeat
  163.     twinkle(me)
  164.     v = the ticks + 10
  165.     repeat while the ticks < v
  166.     end repeat
  167.     pippiType = orgType
  168.     setmember(me)
  169.   end if
  170. end
  171.  
  172. on twinkle me
  173.   pippiType = -1
  174.   setmember(me)
  175.   v = the ticks + 6
  176.   repeat while the ticks < v
  177.   end repeat
  178.   pippiType = 0
  179.   setmember(me)
  180. end
  181.  
  182. on movePippi me, pCnt
  183.   staticPippi = 0
  184.   cursorPos = the mouseLoc
  185.   me.traceCursor(cursorPos)
  186.   if oldFurType <> 8 then
  187.     pippiType = 5
  188.     setmember(me)
  189.     v = the ticks + 25
  190.     repeat while the ticks < v
  191.     end repeat
  192.   end if
  193.   pippiType = random(2) + 5
  194.   setmember(me)
  195.   autoMoveObject.autoMove(pippi, sprite(pCnt).loc)
  196.   v = random(5)
  197.   sound(1).play(member("hopp-" & string(v), 1))
  198.   if furType = 1 then
  199.     pippiType = 5
  200.     setmember(me)
  201.     v = the ticks + 20
  202.     repeat while the ticks < v
  203.     end repeat
  204.   end if
  205.   pippiType = furType
  206.   setmember(me)
  207.   if pCnt = furNum then
  208.     A = value((the frameLabel).char[2])
  209.     b = A + 1
  210.     room = b
  211.     go(string(xFrame) & string(b))
  212.   end if
  213.   sndObject.respondSnd(3, 4, 1, 1)
  214. end
  215.  
  216. on fallPippi me, pCnt
  217.   if fallen = 0 then
  218.     staticPippi = 1
  219.     if oldFurType <> 8 then
  220.       pippiType = 5
  221.       setmember(me)
  222.       v = the ticks + 25
  223.       repeat while the ticks < v
  224.       end repeat
  225.     end if
  226.     pippiType = random(2) + 5
  227.     setmember(me)
  228.     pLoc = the mouseLoc
  229.     qLoc = me.lookForPlaceToFall(pLoc, 250)
  230.     autoMoveObject.autoMove(pippi, qLoc)
  231.     updateStage()
  232.     pippiType = 9
  233.     setmember(me)
  234.     fallen = 1
  235.     sound(1).play(member("duns", 1))
  236.   end if
  237.   updateStage()
  238. end
  239.  
  240. on fallXPippi me
  241.   if fallen = 0 then
  242.     pippiType = 9
  243.     setmember(me)
  244.     pLoc = the mouseLoc
  245.     qLoc = me.lookForPlaceToFall(pLoc, 130)
  246.     autoMoveObject.autoMove(pippi, qLoc)
  247.     fallen = 1
  248.     sound(1).play(member("duns", 1))
  249.   end if
  250.   updateStage()
  251. end
  252.  
  253. on lookForPlaceToFall me, pLoc, pDist
  254.   xLoc = me.testOnFloor(pLoc)
  255.   yLoc = me.testDistance(xLoc, pDist)
  256.   zLoc = me.testInterSectFur(yLoc)
  257.   return zLoc
  258. end
  259.  
  260. on testOnFloor me, pLoc
  261.   xLoc = pLoc
  262.   if inside(xLoc, sprite(5).rect) = 0 then
  263.     xLoc = ((xLoc - pippi.loc) / 2) + ((xLoc - pippi.loc) / 3) + pippi.loc
  264.   end if
  265.   if inside(xLoc, sprite(5).rect) = 0 then
  266.     repeat while inside(xLoc, sprite(5).rect) = 0
  267.       vv = point(400, 300)
  268.       xLoc = ((xLoc - vv) / 2) + ((xLoc - vv) / 3) + vv
  269.     end repeat
  270.   end if
  271.   return xLoc
  272. end
  273.  
  274. on testInterSectFur me, loc1
  275.   pLoc = loc1
  276.   repeat with n = 1 to 10
  277.     repeat with n = furList[1] to furList[2]
  278.       if intersect(rect(pLoc[1] - 15, pLoc[2] - 15, pLoc[1] + 15, pLoc[2] + 15), sprite(n).rect) > rect(0, 0, 0, 0) then
  279.         repeat while intersect(rect(pLoc[1] - 20, pLoc[2] - 20, pLoc[1] + 20, pLoc[2] + 20), sprite(n).rect) > rect(0, 0, 0, 0)
  280.           vv = point(400, 300)
  281.           pLoc = ((pLoc - vv) / 2) + ((pLoc - vv) / 3) + vv
  282.         end repeat
  283.         exit repeat
  284.       end if
  285.     end repeat
  286.   end repeat
  287.   return pLoc
  288. end
  289.  
  290. on testDistance me, loc2, pDist
  291.   dist = pDist
  292.   loc1 = pippi.loc
  293.   loc1a = pippi.loc
  294.   loc2a = loc2
  295.   repeat with n = 1 to 10
  296.     H = loc2a[1] - loc1a[1]
  297.     v = loc2a[2] - loc1a[2]
  298.     A = H
  299.     b = v
  300.     if A < 0 then
  301.       A = A * -1
  302.     end if
  303.     if b < 0 then
  304.       b = b * -1
  305.     end if
  306.     if A > b then
  307.       c = A
  308.     else
  309.       c = b
  310.     end if
  311.     if c > dist then
  312.       loc2a = ((loc2a - loc1) / 2) + ((loc2a - loc1) / 4) + loc1a
  313.       next repeat
  314.     end if
  315.     pLoc = loc2a
  316.     exit repeat
  317.   end repeat
  318.   return pLoc
  319. end
  320.